import zmq

class Pair:
    def __init__(self, port):
        self.port = port
        self.context = zmq.Context()
        
    def createReceiver(self):
        self.socket = self.context.socket(zmq.PAIR)
        self.socket.bind(f"tcp://*:{self.port}")
        
    def send(self, ip, msg):
        self.socket = self.context.socket(zmq.PAIR)
        self.socket.connect( f"tcp://{ip}:{self.port}")
        self.socket.send_string(msg)
        self.socket.close()
        
    def recv(self):
        return self.socket.recv_string()
